// component/xuanshou/xuanshou.js
import {voteModel} from "../../../model/vote"
import {config} from "../../../config"
var vote = new voteModel()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    mode2:{type:Object}
  },

  /**
   * 组件的初始数据
   */
  data: {
  person:"../xuanshou-image/person.png",
  bianhao:"../xuanshou-image/圆角矩形 18.png",
  bianhao_text:"01号",
  xinxi_image:"../xuanshou-image/组 27.png",
  name:"张萍萍   35岁",
  piaoshu:"114票",
  tall_image:"../xuanshou-image/组 27_2.png",
  tall:"170cm",
  weight_image:"../xuanshou-image/组 27_1.png",
  weight:"55kg",
  jieshao:"个人介绍个人介绍个人介绍个人介绍",
  toupiao_image:"../xuanshou-image/圆角矩形 8.png",
  toupiao:"点击投票",
  },

  /**
   * 组件的方法列表
   */
  methods: {
    toupiao(){
      console.log("aaaa")
    },
    //跳转详情页
  toTianjinzhimei:function(e){
    console.log(this.properties.mode2);
    wx.navigateTo({
      url: '/pages/vote/detail/detail?id='+this.properties.mode2.id,
    })
  },
  Vote(){
    if(config.isMobile !="1"){
      wx.navigateTo({
        url: '/pages/login/login',
      })
    }else{
    vote.vote(this.properties.mode2.id).then(
      res=>{
        if(res.code === 0){
          wx.showToast({
            title:'投票成功！',        
            icon:'success',         
            duration: 2000         
          })    
        }else{
          wx.showToast({
            title:res.msg,        
            icon:'none',         
            duration: 2000         
          }) 
        }
      }
    )
    }
  },
  }
})
